Using Postscript Fonts with Professional Page
By Douglas J. Nakakihara

	When GoldDisk first put Compugraphic (CG) font support into Professional Page (PPage), Postscript printers were prohibitively expensive, and this outline font technology provided comparable print quality on non-Postscript printers. The FontManager utility was suppose to convert Postscript fonts into CG format, but it often failed. Soft-Logik's TypeSmith ($199.95) has a higher success rate, but still falls short of perfection, especially on really complex PD (public domain) fonts. However, with Postscript printers now selling for well under $1,000, it's time to look into how Postscript fonts can be used with PPage without CG-conversion.

	PPage already handles the "basic" 35 Postscript fonts (Times, Helvetica, etc.) that are built into most Postscript printers. However, installing additional Postscript fonts to work automatically with PPage is not well documented. Fortunately, it is not that difficult. All you need is Amiga bitmapped versions of the font and metric files, plus the Postscript font in downloadable format. The basic programs required to generate the files are PD and available on most BBSs. However, there may be circumstances when TypeSmith is needed.

	Since the display will be using Amiga bitmapped fonts, screen updates will be lightning-fast. Your documents will also print faster and look sharper. However, fonts will not look nearly as good on your monitor--PPage will make liberal use of it's "greeking" feature. (If you need the best possible screen fonts, you can use a CG version of a font instead of an Amiga bitmapped font. However, this will result in essentially redundant files stored on your hard disk with no difference in printed output.)

Postscript Font Files

	I'll be using the MS-DOS naming convention (eight characters plus a three-character extension), since it is commonly used for Postscript fonts. There are usually several files for each font; however, you only need the one with a .PFB extension and the one with an .AFM extension.

	The PFB file contains the information describing each character in the font. The AFM file contains the font width and kerning information. If the AFM file is missing, you can use TypeSmith to generate one. (There are public domain utilities that do this, but I have never had much luck with them.)

Amiga Tools

	The first utility we need is "Post" by Adrian Aylward. (On BIX the archive is called "POST17B.LZH" and is 211k.) This is a Postscript interpreter and a story all by itself. (Suffice it to say, you can use it to print Postscript output on non-Postscript printers.) You only need "Post.library" and "Init.ps" from this archive. Do the following:

	1) Copy "Post.library" to your LIBS: directory.
	2) Create a directory on your hard disk called PSFonts.
	3) Copy "Init.ps" to the PSFonts directory.
	4) Assign the name "PSFonts:" to this directory. (You might want to add this assignment in your User-Startup file.)

	The next utility you'll need is "Font Manipulator for DTP," also by Aylward. (BIX: FMDTP3.LZH, 90k.) Again there are numerous files and you only need a few. Execute the following steps:

	1) Copy "Mkbmap" to your C: directory.
	2) Copy "Mkmetric" to your C: directory.
	3) Copy "ppext_encoding.ps" to your PSFonts: directory, but rename it "encoding.ps".

	Finally you'll need "PS Download" by Mike Todd. (BIX: PSDL.LZH, 7k.) There are only two files in this archive, the program and the documentation file. Copy the program to your C: directory.

TypeSmith Filtering

	I had no problems with real Adobe Postscript fonts. However, I found that Mkbmap wouldn't work with many of the PD fonts I had--especially those created with "Fontographer," which most of mine were. (View the PFB file with a text viewer for an indication of the font's origin.) Fortunately, I found that if I imported a PFB file into TypeSmith and then just exported it as a PFB file, Mkbmap was a happy camper. Essentially, you won't know if TypeSmith is required until you try to use Mkbmap.

Bitmapped Fonts

	Mkbmap will create an Amiga bitmapped font from a PFB file (e.g., DOUGSDEL.PFB). The PFB file must be copied to the PSFonts: directory and renamed using the real font name (e.g., Dougsdelight). The renaming is extremely important! The following command at any CLI prompt will get it done in one step. I'll assume the PFB file is on a floppy disk in DF0: and use my example names:

	copy  df0:dougsdel.pfb  psfonts:Dougsdelight

	You can determine the real name of a font by using a text viewer on the AFM file. Look for the text "FontName" near the beginning of the file. The font name will follow this (e.g., "FontName Dougsdelight"). You must use the exact name, including any dashes (-), and it is case-sensitive. Make sure you use the "FontName" and not the "FullName", as they are not always the same.

	To create a 12 and 24 point Amiga bitmapped font in your FONTS: directory called "Dougsdelight," execute the following command:

	mkbmap  -n  fonts:Dougsdelight/*  Dougsdelight  12,24

	If you want to create additional font sizes just add them to the command, separated by commas. However, a 12 and 24 point font should be adequate, since PPage can resize them on the fly. (Not always a pretty sight, however.) You might want to create more sizes for frequently used fonts to make them more legible on screen. (You don't really have to use the real name after "fonts:"; however, I suggest you do so when possible to keep things uniform.)

	If you have a problem at all, it will probably occur with Mkbmap. If you get a "Post: error: invalidfont, command --findfont--" error, check that the real font name is spelled exactly right, including case. If you get a similar error, but with "command --charpath--" at the end, it may be that Mkbmap just can't convert the font. (Note: only six of my 700 fonts failed (after TypeSmith filtering), mostly because of defective original PFB files.) In any event, after getting an error, recheck all steps.

Metric File

	The AFM file doesn't have to be in the PSFonts: directory and you don't have to rename it. Just issue the following command:

	mkmetric  fonts:Dougsdelight.metric  df0:dougsdel.afm

	Although you can optionally append the bold, italic, and bold-italic version AFM files to the above command, I don't recommend it. It's better to treat each version as a separate independent font. Otherwise, you'll waste time trying to figure out if you have the bold or italic versions of a particular font. PPage's bold and italics styles will work on your screen, but will not print out that way. You need to have separate bold and italic Postscript font files, it cannot be derived from the plain version.

Shortened Filenames

	If the real font name is longer than 23 characters, you'll need to use a shortened name when creating the bitmapped font and metric. (PPage will still be able to download the correct Postscript font because its real name is embedded in the Amiga font file.) Here is an example:

	mkbmap  -n  fonts:Superlongfn-ExtraBold/*  Superlongfilename-ExtraBold  12,24
	mkmetric  fonts:Superlongfn-ExtraBold.metric  df0:superlgf.afm

	If you already ran Mkbmap or Mkmetric, just rename the two files and directory that were created in the FONTS: directory with shortened names. Be sure the .font and .metric extensions are spelled out and run the AmigaDOS program "Fixfonts" afterward.	

Downloadable Fonts

	The PFB file contains all of the necessary font information, but because it's partially compressed, you need to convert it into something more palatable to your printer. To do this, use PSDownload as follows:

	psdownload  >cgfonts:ps/Dougsdelight.psfont  -f  psfonts:Dougsdelight

	This will create a downloadable-formatted Postscript font file in the CGFonts:ps directory. Don't forget the "-f" switch. The program will still work if you leave it out, but the font won't work right in PPage. Trust me!

Using the Fonts

	After you convert a font or two, try using them in PPage. They should appear alphabetically in the Typeface list, after the CG fonts. (Any fonts in the FONTS: directory that have a .metric file will appear.) 

	If they don't appear in the list or on screen when you type something, try creating the bitmapped font and metric file again. Also check the FONTS: directory to see if the font files are there. If the font passed Mkbmap's scrutiny, it should work!

	If the screen looks OK, output the document to your Postscript printer (right-Amiga p). Make sure the "Include Downloadable Fonts" button is selected and click OK. PPage should indicate it is downloading the font(s) in the dialog box that pops up.

	If all went well, your text will be printed in all of the glory of Postscript. If not, then there is a problem with the downloadable Postscript file. Try creating it one more time. Again, if the font passed Mkbmap's scrutiny, it should work! However, I had two fonts that looked fine on screen, but would cause a page not to print if used.

Font Character Problems

	With PD fonts, you'll sometimes find the space character width is off or there are missing characters. This is usually a problem with the actual PFB file and you need to edit it with TypeSmith and create new PFB and AFM files.

Automation

	To automate the above process, I have written two ARexx scripts. "PFB2PFB.tsrx" is optional and filters the PFB files using TypeSmith. The second script, "MakePS4PPage.rx," generates the bitmapped, metric, and downloadable files.

	Both scripts need a data file as an argument, containing a vertical listings of all of the PFB files. An easy way to create the list is described in the scripts' remarks.

CG Fonts

	Unless you're going to use them in another program, like ProDraw, there is little reason to keep any redundant CG fonts. You can always recreate them again later on an as-needed basis.

Long Boot

	The only real problem of using Postscript fonts in this manner occurs if you have hundreds of them. PPage does not store a list of bitmapped fonts, like it does for CG fonts. As a result, it must create the list of available fonts every time you boot PPage. With about 700 fonts, it takes over ten minutes before the PPage screen comes up on my A3000!

Separate Fonts: Directory

	Now if all of your bitmapped fonts are stored in FONTS:, you'll get a long delay with any program that attempts to bring up a list of fonts. If you don't run PPage all of the time, put the generated Amiga fonts and metrics into a directory other than FONTS: (i.e., substitute this path for "FONTS:" in the Mkbmap and Mkmetric command lines described above). I use  a directory called "fonts" under PPage:. Boot PPage using a short script file that assigns FONTS: to this directory before running PPage. The original FONTS: assignment can be restored after exiting PPage. Here is an example:

	Assign  FONTS:  PPage:fonts
	Stack  10000
	PPage:ppage  -its
	Assign  FONTS:  SYS:fonts

	Note: Use IconX to automate this for running from Workbench.

	Since you'll probably never use all of your fonts, keep them in a directory called Font.storage under PPage:. Then, on an as-needed basis, before you boot PPage, copy or move the pertinent font files to the ppage:fonts directory.

FontcacheX

	Steve Tibbet's FontcacheX (another PD program) can provide some relief. FontcacheX saves the list of available fonts in memory after the first time any program requests it. After that, anytime any program requests the available fonts, you get instant response. Unfortunately, if you change the FONTS: assignment or add new fonts, FontcacheX will still remember the original list. I wish FontcacheX would save the list to a file, so it wouldn't have to start all over each time you turn your computer on. As it stands now, I recommend FontcacheX only if often run PPage multiple times without rebooting.

Summary

	Using Postscript fonts with PPage has eliminated a frustrating need to convert Postscript fonts to CG. Since GoldDisk is no longer upgrading--but supposedly still supporting--PPage, the long boots will have to be tolerated or you can use one of the workarounds. In any event, I finally have access to hundreds of fonts that I could never convert to CG format--life is good.

/**********************************************************
PFB2PFB.tsrx

   An AREXX Script to "filter" PFB files by importing and
   then exporting them using TypeSmith by Soft-Logik. This
   was written to be executed from TypeSmith; however, you
   can also run it from the CLI (while TypeSmith is
   running).

   SYNTAX: PFB2PFB.tsrx <Fontlist>

   --"Fontlist" is an ASCII file containing a list of PFB
   files. This file can be created very easily using the
   AmigaDOS 'LIST' command. If the PFB files were on a
   floppy disk in DF0: you would do the following:

     1) Execute this command:
        List  >ram:Fontlist  DF0:#?.PFB

     2) Using a text editor, delete non-filename lines in
        the file ram:Fontlist. It is not necessary to
        delete the information that follows the filenames
        (i.e., file size, creation date, etc.).

     3) Execute this command:
        Sort from ram:Fontlist to work:Fontlist

     Substitute pathnames to suit your system.

**********************************************************/

Parse arg infile

Address 'TYPESMITH'
Options results

/* Display error if no fontlist file is provided */
If infile = '' then do
   display_alert 'Syntax: PFB2PFB.tsrx <FontList>|Exit'
   Exit
End

/* Display error if unable to read fontlist file */
If open('textfile', infile, 'read') = 0 then do
   display_alert 'Unable to locate Infile.|Exit'
   Exit
End

/* Set these variables to your match your system.
   -Inpath is the directory where the PFB files are.
   -Outpath is the directory where you want the new PFB
    files to be saved.  These can be the same if you want
    to overwrite the original PFB file.
   -Ending slash (/) is needed if path is not the root
    dir.
*/
inpath = 'DF0:'
outpath = 'Work:PFB/'

Do while eof('textfile') = 0
   /* Extract fontname */
   /* NOTE: There is a space between these single quotes */
   fontname = readln('textfile') || ' '
   aaa = pos(' ', fontname)
   fontname = left(fontname, aaa-1)

   If aaa > 1 then do
      Say 'reading: '  ||  fontname

      /* Import the PS font */
      import_pfb inpath  ||  fontname
      If rc > 0 then do
         display_alert 'Import PFB failed.|Exit'
         Exit
      End
      show_filled 1

      export_pfb outpath  ||  fontname
      If rc > 0 then do
         display_alert 'Export PFB failed.|Exit'
         Exit
      End
      close_font
   End
End
Exit



/**********************************************************
MakePS4PPage.rx

   An AREXX Script to automate the use of MKBMAP,
   MKMETRIC, and PSDOWNLOAD.  Script assumes these
   programs have been installed per their documentation.

   SYNTAX: MakePS4PPage.rx <Fontlist>

   --"Fontlist" is an ASCII file containing a list of PFB
   files. This file can be created very easily using the
   AmigaDOS 'LIST' command. If the PFB files were on a
   floppy disk in DF0: you would do the following:

   1) Execute this command:
      List  >ram:Fontlist  DF0:#?.PFB

   2) Using a text editor, delete non-filename lines in 
      the file ram:Fontlist. It is not necessary to
      delete the information that follows the filenames
      (i.e., file size, creation date, etc.).

   3) Execute this command:
      Sort from ram:Fontlist to work:Fontlist

     Substitute pathnames to suit your system.

   Specifically, the script does the following:

   1) Copy the PFB file in the current dir to PSFonts:
      using the fontname as the filename.

   2) Create a downloadabe PS font file in the CGFonts:PS
      dir using DownloadPS with -F option.

   3) Create 12 and 24 point bitmapped fonts in FONTS:
      using Mkbmap.

   4) Create the metric file in FONTS: using Mkmetric.

   5) Clean up and delete PFB file in PSFonts:

   NOTES:

   - Run this script from the directory containing the PFB
     and AFM files.

   - If you redirect screen output to a file, that file
     can be examined later for errors. For example:

     rx  >ram:read.txt rexx:makeps4ppage.rx  work:fontlist

   - Highly recommend PFB files be imported and exported
     with TypeSmith before running this.

**********************************************************/

Parse arg infile
Options results

/* Display error if no fontlist file is provided */
If infile = '' then do
   say 'Syntax: MakePS4PPage.rx [FontList]'
   Exit
End

/* Display error if you are unable to read fontlist file */
If open('textfile',infile,'read') = 0 then do
   Say 'Unable to locate Infile.'
   Exit
End

Do while eof('textfile') = 0
   /* Extract fontname */
   /* There is a space between these single quotes */
   filename = readln('textfile') || ' '
   aaa = pos(' ', filename)
   filename = left(filename, aaa-1)

   /* PFB file has to be longer than 4 characters (.PFB) */
   If length(filename) > 4 then do

      /* Search through PFB file for real fontname */
      Call Findname
      Say 'Processing: ' || fontname || '(' || filename
|| ')'

      /* Calculate AFM filename. */
      bbb = pos(".", filename)
      metricfile = left(filename, bbb-1) || '.afm'

      Say '  Copy PFB file to PSFonts: and rename using
real font name...'
      Address command 'copy ' || filename || ' psfonts:'
|| fontname

      Say '  Creating downloadable PS font...'
      Address command 'c:psdownload >CGFonts:ps/'
|| fontname || '.psfont ' || '-f psfonts:' || fontname

      Say '  Creating bitmapped font...'
      Address command 'c:mkbmap -n fonts:' || fontname
|| '/* ' || fontname || ' 12,24'

      Say '  Creating bitmapped metric font...'
      Address command 'c:mkmetric fonts:' || fontname
|| '.metric ' || metricfile

      Say '  Deleting files copied to PSFonts:...'
      Address command 'delete >nil: psfonts:' || fontname
   End
End
Exit


Findname: procedure expose filename fontname

/* This subroutine searches through the PFB file and then
   finds and stores the real fontname.
*/

If open('pfbfile', filename, 'read') then do
   aaa = 0
   Do while aaa = 0
      /* If end of file reached, display error message. */
      If eof('pfbfile') then do
         Say '/FontName string not found!'
         Close('pfbfile')
         Exit
      End

      /* Read a line from file */
      alin = readln('pfbfile')

      /* Look for string: /FONTNAME, using upper case */
      aaa = pos('/FONTNAME', upper(alin))
   End

   /* Extract fontname string */
   beg = pos('/', alin, aaa + 1) + 1

   /* There is a space between the single quotes */
   len = pos(' ', alin, beg) - beg

   fontname = substr(alin, beg, len)
   Close('pfbfile')
End
Else do
   Say '>>>> ERROR: Cannot open PFB file'
   Exit
End
Return


